import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { TPetManual } from "../../../../../Message/Db/Tables/TPetManual";
import { Language } from "../../../../../extend/language/Language";
import { Cache } from "../../../cache/Cache";
import { GImageBitmap } from "../../../../../com/mui/controls/GImageBitmap";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ObjCreate } from "../../common/ObjCreate";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { PetModelPanel } from "../PetModelPanel";
import { BaseItem } from "../../common/BaseItem";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
//class PetIlluListRenderer
    
    export  class PetIlluListRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._petManual = arg1 as TPetManual;
            if (this._petManual) 
            {
                this._nameTxt.text = this._petManual.name;
                this._avatarBaseItem.source = this._petManual.propertyTwo + ".png";
                if (this._petManual.type != 0) 
                {
                    if (this._petManual.type != 1) 
                    {
                        if (this._petManual.type == 2) 
                        {
                            this._typeTxt.text = Language.getString(54073);
                            this._attackTypeTxt.text = Language.getString(54070);
                            this._attrTxt.text = Language.getString(54074);
                        }
                    }
                    else 
                    {
                        this._typeTxt.text = Language.getString(54071);
                        this._attackTypeTxt.text = Language.getString(54072);
                        this._attrTxt.text = Language.getString(54072);
                    }
                }
                else 
                {
                    this._typeTxt.text = Language.getString(54069);
                    this._attackTypeTxt.text = Language.getString(54070);
                    this._attrTxt.text = Language.getString(54070);
                }
                this._infoTxt.htmlText = "<textFormat leading=\'5\'>" + this._petManual.info + "</textFormat>";
                this._modelPanel.updateModelByModelId(this._petManual.propertyOne);
                this._modelPanel.drawNow();
                this._isHad = !(Cache.instance.pet.collectedPets.indexOf(this._petManual.propertyThree) == -1);
                if (this._isHad) 
                {
                    this._labelBitmap.bitmapData = new GImageBitmap(ImagesConst.GetedLabel).bitmapData;
                }
                else 
                {
                    this._labelBitmap.bitmapData = new GImageBitmap(ImagesConst.GetNotLabel).bitmapData;
                }
            }
            return;
        }

        /* internal  */init(): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=0;
            ObjCreate.createBg(0, 0, 500, 220, this);
            loc1 = 260;
            loc2 = 330;
            loc3 = 75;
            this._modelBg = new Object /* flash.display.Bitmap */();
            this._modelBg.x = 2;
            this._modelBg.y = 5;
            this.addChild(this._modelBg);
            LoaderHelp.setBitmapdata("IllustrationModelBg.swf", this._modelBg);
            this._modelPanel = new PetModelPanel();
            this._modelPanel.x = 120;
            this._modelPanel.y = 150;
            this.addChild(this._modelPanel);
            this.addChild(new GImageBitmap(ImagesConst.PetNameBg, loc1, 5));
            this._labelBitmap = new GImageBitmap(ImagesConst.GetNotLabel, 365, 60);
            this.addChild(this._labelBitmap);
            this._avatarBaseItem = new BaseItem();
            this._avatarBaseItem.setSize(48, 48);
            this._avatarBaseItem.move(278, 10);
            this.addChild(this._avatarBaseItem);
            this._nameTxt = ObjCreate.createTextField("", 340, 32, 115, 20, this, GlobalStyle.textFormat8);
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            ObjCreate.createTextField(Language.getString(54075), loc1, loc3, 115, 20, this);
            this._typeTxt = ObjCreate.createTextField("", loc2, loc3, 115, 20, this, GlobalStyle.textFormat2);
            this._typeTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            loc3 = loc3 + 20;
            ObjCreate.createBg(loc1, loc3 - 2, 210, 2, this, ImagesConst.SplitLine);
            ObjCreate.createTextField(Language.getString(54076), loc1, loc3, 115, 20, this);
            this._attackTypeTxt = ObjCreate.createTextField("", loc2, loc3, 115, 20, this, GlobalStyle.textFormat2);
            this._attackTypeTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            loc3 = loc3 + 20;
            ObjCreate.createBg(loc1, loc3 - 2, 210, 2, this, ImagesConst.SplitLine);
            ObjCreate.createTextField(Language.getString(54077), loc1, loc3, 115, 20, this);
            this._attrTxt = ObjCreate.createTextField("", loc2, loc3, 115, 20, this, GlobalStyle.textFormat2);
            this._attrTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            loc3 = loc3 + 20;
            ObjCreate.createBg(loc1, loc3 - 2, 210, 2, this, ImagesConst.SplitLine);
            ObjCreate.createTextField(Language.getString(54078), loc1, loc3, 115, 20, this);
            this._infoTxt = ObjCreate.createTextField("", loc2, loc3, 145, 55, this, GlobalStyle.textFormat2);
            this._infoTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._infoTxt.multiline = true;
            this._infoTxt.wordWrap = true;
            return;
        }

        /* internal */ /* var */_modelBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_labelBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_modelPanel: PetModelPanel;

        /* internal */ /* var */_avatarBaseItem: BaseItem;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_typeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_attackTypeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_attrTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_infoTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_petManual: TPetManual;

        /* internal */ /* var */_isHad: Boolean;
    }
